import http from '@src/util/http'

const prefix = '/api/warehouse';

/**
 * @description 获取物流公司列表
 * @param {Object} params 参数
 * params.companyName 物流公司名称, 可为空，默认全部
 * 
 */
export function getLogisticsCompanyList(params: Record<string, any>) {
  return http.get(`${prefix}/outside/out/warehouse/flow/company/list`, params)
}

/**
 * 个人库存
 * @param {Object} params - 参数
 */
export function getPersonalInventoryList(params: Record<string, any>) {
  return http.post(`${prefix}/outside/personal/inventory/list`, params);
}

/**
 * 物料-查询
 * @param {Object} params - 参数
 * @param {String} params.keyword - 关键字
 */
export function getMaterialList(params: {} | undefined) {
  return http.post(`${prefix}/outside/material/list`, params);
}

/**
 * 物料申领 - 个人仓库情况
 * @param {Object} params 参数对象
 */
 export function getPersonalInventoryWarehouse(params: {} | undefined) {
  return http.post(`${prefix}/outside/personal/inventory/warehouse`, params);
}

/**
 * 物料返还 - 仓库列表
 * @param {Object} params 参数对象
 */
 export function getWarehouseSearch(params: {} | undefined) {
  return http.get(`${prefix}/outside/warehouse/search`, params);
}

export function getTaskWarehouseSearch(params: {} | undefined) {
  return http.get(`/api/task/outside/pc/warehouse/get`, params);
}

/**
 * 物料返还 - 仓位
 * @param {Object} params 参数对象
 */
 export function getWarehousePositionSearch(params: {} | undefined) {
  return http.get(`${prefix}/outside/warehousePosition/search`, params);
}

/**
 * 查询物料申领出库物流信息
 * @param {Object} params 参数对象
 * @param {String} params.logisticsNo 物流单号
 * @param {String} params.companyType 公司类型
 */
 export function getWarehouseFlowLogistics(params: {} | undefined) {
  return http.get(`${prefix}/outside/out/warehouse/flow/logistics`, params);
 }

/**
 * @description sn列表查询
 */
export function getInventorySNList(params = {}) {  
  return http.get(`${prefix}/outside/inventory/sn`, params);
}

/**
 * 物料核销 - 个人库
 * @param {Object} params 参数对象
 */
 export function getPersonalInventoryWarehouseList(params: {} | undefined) {
  return http.get(`${prefix}/outside/personal/inventory/warehouse/list`, params);
}

/**
 * 物料核销 - 个人仓位
 * @param {Object} params 参数对象
 */
 export function getWarehousePositionListSearch(params: {} | undefined) {
  return http.post(`${prefix}/outside/warehousePosition/list/search`, params);
}

/**
 * 物料库存列表-列表查询
 * @param {Object} params 参数对象
 * @param {String} params.materialId - 物料ID
 * @param {String} params.warehouseId - 仓库ID
 * @param {String} params.positionId - 仓位ID
 */
 export function getInventoryList(params: {} | undefined) {
  return http.post(`${prefix}/outside/inventory/list`, params);
}

/**
 * 物料核销 - 根据sourceId(工单ID)获取已经完成出库的物料信息
 * @param {Object} params 参数对象
 * @param {String} params.sourceId - 工单ID
 */
 export function getOutWarehouseMaterialFinished(params: {} | undefined) {
  return http.post('/api/task/outside/pc/warehouse/outbound/data', params);
}

/**
 * 物料核销 - 获取个人库和仓库的物料信息
 * @param {Object} params 参数对象
 * @param {String} params.sourceId - 工单ID
 */
export function getWarehousePersonDataApi(params: {} | undefined) {
  return http.post('/api/task/outside/pc/warehouse/inventory/data', params);
}


/**
 * 物料核销 - 检查当前sourceId下的工单出库是否都已完成
 * @param {Object} params 参数对象
 * @param {String} params.sourceId - 工单ID
 */
 export function getOutWarehouseFlowFinished(params: {} | undefined) {
  return http.get(`${prefix}/outside/out/warehouse/flow/isFinished`, params);
}

/**
 * 获取默认出库的仓库和仓位
 * @param {Object} params 参数对象
 * @param {String} params.outWarehouseTypeInitEnum - 出库类型（申领出库）
 * @param {String} params.tagId - 组织id	
 * @param {String} params.tagType - 组织类型	
*/
export function getDefaultWarehouse(params: {} | undefined) {
 return http.post(`${prefix}/outside/warehouse/default/out/warehouse/get`, params);
}

/**
 * 库存校验接口(校验SN是否有误)
 * @param {Object} params 参数对象
 * @param {String} params.positionId - 库位主键
 * @param {String} params.warehouseId - 仓库主键	
 * @param {String} params.materialSnMap - 物料id	
*/
export function validInventorySn(params: {} | undefined) {
  return http.post(`${prefix}/outside/inventory/valid`, params);
 }

/**
* @description 获取物料列表
*/
export function getSparePartV3List(params = {}) {
  return http.post(`${prefix}/outside/material/serviceShopGetByPage`, params);
}

/**
* @description 获取备件3.0仓库列表
*/
export function getWarehouseV3List(params = {}) {
  return http.post(`${prefix}/outside/warehouse/list/serviceShopPage`, params);
}

/**
* @description 获取备件列表
*/
export function getSparePartV2List(params = {}) {
  return http.post('/api/part/outside/sparepart/getSparePartList', params);
}

/**
* @description 获取备件2.0仓库列表
*/
export function getWarehouseV2List(params = {}) {
  return http.post('/api/part/outside/dd/part/repertory/serviceShopGetRepertoryPage', params);
}

/**
 * 获取默认仓库仓位库存
 * @param 
 * @returns 
 */
export function getDefaultWarehouseBinInventory(params = {}) {
  return http.post('/api/task/outside/pc/warehouse/out/recommend/get', params)
}